package cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.service;

import cn.maihe.elg.operation.model.dto.InnerBaseResp;
import cn.maihe.elg.operation.service.order.GuaranteeAttachmentInfoService;
import cn.maihe.elg.operation.supports.electronicseal.kt.KtConfig;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.BaseKtCloudSignService;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.dto.ContractDownloadReqDTO;
import cn.maihe.elg.operation.supports.electronicseal.kt.cloudsign.enums.CloudSignInterfaceEnum;
import cn.maihe.elg.operation.supports.system.ElgResourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description
 * @Author WJH
 * @Date 2022/09/07
 */
@Service
@Slf4j
public class ContractDownloadPdfService extends BaseKtCloudSignService<ContractDownloadReqDTO, byte[]> {
    public ContractDownloadPdfService(KtConfig ktConfig) {
        super(ktConfig);
    }

    @Resource
    private ElgResourceService elgResourceService;
    @Resource
    private GuaranteeAttachmentInfoService guaranteeAttachmentInfoService;

    @Override
    protected CloudSignInterfaceEnum serviceName() {
        return CloudSignInterfaceEnum.contractDown;
    }

    @Override
    public InnerBaseResp<?> doRequest(String traceId, ContractDownloadReqDTO reqDTO) {
        return super.doRequest(traceId, reqDTO);
    }

    public byte[] downloadPdf(String acceptOrderNo, String downloadFileId) {
        ContractDownloadReqDTO reqDTO = new ContractDownloadReqDTO();
        reqDTO.setFileId(downloadFileId);

        InnerBaseResp innerBaseResp = this.doRequest(acceptOrderNo, reqDTO);
        return this.parseInnerBaseResp(innerBaseResp);

    }
}
